package com.web_bloks.widget.client;

import com.web_bloks.system.client.Logger;
import com.google.gwt.http.client.Response;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Widget;

/**
 * SMSWidget   ##BROKEN##
 * 
 *  A short message service
 *  
 * @author Jean-Lou Dupont
 *
 * <div target="element-id" cond="condition" msg="some-message" />
 *
 */
public class SMSWidget 
	extends CollectionableWidget 
	implements WidgetCommand {

	final static String thisClass = "com.web_bloks.widget.SMSWidget";
	
	/*****************************************
	 * Constructor 
	 *****************************************/
	public SMSWidget() {
		super();
	}
	public SMSWidget(Element parent, Element source) {
		super();
		this.initFromDOMElement(parent, source);
	}

	/*****************************************
	 * API 
	 *****************************************/
	public String getTarget() {
		return this.getElement().getAttribute("target");
	}
	
	public String getCond() {
		return this.getElement().getAttribute("cond");
	}

	public String getMsg() {
		return this.getElement().getAttribute("msg");
	}
	/*****************************************
	 * WidgetCommand 
	 *****************************************/
	public void executeWidgetCommand(Widget source, String cond, Response response) {
		//Window.alert("SMSWidget.executeWidgetCommand");
		String id = this.getElement().getAttribute("id");
		Logger.logInfo(thisClass+".executeWidgetCommand, id["+id+"] cond["+cond+"]");
		
	}
	
	/*****************************************
	 * WidgetEx 
	 *****************************************/
	
	public void initFromDOMElement(Element parent, Element source){
		
		this.setElement(source);
		String id = this.getElement().getAttribute("id");
		setId(id);
	}

	/*****************************************
	 * HELPERS 
	 *****************************************/

	protected String extractMessage(Response response) {
		
		if ( null == response )
			return null;
		
		return null;
	}
	
}//
